/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 artifact_prop_ability.cpp

	$Header: /heroes4/artifact_prop_ability.cpp $

	$NoKeywords: $

 ************************************************************************/

#include "precompiled.h"
#include "artifact_prop_ability.h"

#include "artifact_effect_visitor.h"
#include "streambuf_operators.h"

using namespace t_artifact_prop;

// ----------------------------------------------------------
// artifact which gives a creature ability
// ----------------------------------------------------------
bool t_give_ability::accept( t_artifact_effect_visitor& visitor )
{
	return visitor.visit_ability( *this );
}

// ----------------------------------------------------------
// artifact which gives a creature ability
// ----------------------------------------------------------
t_artifact_effect* t_give_ability::clone() const
{
	return new t_give_ability( *this );
}

// ----------------------------------------------------------
// artifact which gives a creature ability
// ----------------------------------------------------------
t_artifact_effect* t_give_ability::create()
{
	return new t_give_ability;
}

// ----------------------------------------------------------
// artifact which gives a creature ability
// ----------------------------------------------------------
bool t_give_ability::read( std::streambuf& buffer )
{
	if (!t_artifact_effect::read( buffer ))
		return false;
	m_ability = t_creature_ability( get<t_uint8>( buffer ));
	return true;
}

// ----------------------------------------------------------
// artifact which gives a creature ability
// ----------------------------------------------------------
bool t_give_ability::write( std::streambuf& buffer ) const
{
	if (!t_artifact_effect::write( buffer ))
		return false;
	put<t_uint8>( buffer, m_ability );
	return true;
}
